<%@ page contentType="text/html; charset=utf-8" language="java"%>
<!DOCTYPE html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
	<%@include file="/static/common/header.jsp"%>
	<%@include file="/static/common/easyui.jsp"%>
	<%@include file="/static/common/common.jsp"%>
	<link href="${ctx}/static/css/main.css" rel="stylesheet">

<script>  

$(document).ready(function(){
	
	$('#callOrderTable').datagrid({
		title:'工单列表信息',
		iconCls:'icon-bumen',
		method:'post',
		width:665,
		height:450,
		nowrap: false,
		striped: true,
		collapsible:false,
		url: '${ctx}/infobird/call/orderlist?orderType=1',
		idField:'id',
		columns:[[
			{field:'orderType',title:'工单类型',align:'center',width:120,hidden:true,
				formatter:function(value){
					if(value==""||value==null){
						return "";
					} else if(value=="1") {
						return "话务工单";
					} else if(value=="2") {
						return "结算工单";
					} else {
						return "";
					}
				}
			},
			{field:'orderNo',title:'工单编号',align:'left',width:120},
			{field:'businessFlow',title:'业务类型',align:'left',width:300},
			{field:'remark',title:'备注',align:'left',width:120},
			{field:'status',title:'处理状态',align:'center',width:120,hidden:true,
				formatter:function(value){
					if(value==""||value==null){
						return "处理中";
					} else if(value=="0") {
						return "处理中";
					} else if(value=="1") {
						return "已退回";
					} else if(value=="2") {
						return "已处理";
					}
				}
			},
			{field:'acctNo',title:'交易账号',align:'center',width:100},
			{field:'createUser',title:'创建者',align:'center',width:120},
			{field:'createTime',title:'创建时间',align:'center',width:100, formatter:formatterdate},
			{field:'dealUser',title:'处理者',align:'center',width:120},
			{field:'dealTime',title:'处理时间',align:'center',width:100, formatter:formatterdate},
			{field:'dealFlag',title:'是否已处理',align:'center',width:80,
				formatter:function(value){
					if(value==""||value==null){
						return "否";
					} else if(value=="Y") {
						return "是";
					} else if(value=="N") {
						return "否";
					}
				}
			},
			{field:'id',title:'操作',width:160,rowspan:2,formatter:function(value, row, index){
				var oper = '<a href="#" class="viewcls" onClick="dealOrder(\''+row.id+'\', \''+row.orderType+'\', \'VIEW\')">[ 查看 ]</a>';
				if(row.dealFlag=='N'){
					oper += '<a href="#" class="dealcls" onClick="dealOrder(\''+row.id+'\', \''+row.orderType+'\', \'DEAL\')">[ 处理 ]</a>';
				}
				return oper;
			}},
		]],
		pagination:true,
		pageSize:10,
		rownumbers:true,
		
		toolbar:'#tb',
		onLoadSuccess:function(){
			$('.viewcls').linkbutton({text:'查看',plain:true,iconCls:'icon-view'}); 
			$('.dealcls').linkbutton({text:'处理',plain:true,iconCls:'icon-edit'}); 
			$('#callOrderTable').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		}
	});
	
});

	function addrow() {
		openWin('新增结算工单', '${ctx}/infobird/call/addWin?opt=NEW' + '&stmp=' + (new Date()).getTime());
	}

	//表格查询
	function searchData() {
		var params = $('#callOrderTable').datagrid('options').queryParams; //先取得 datagrid 的查询参数
		var fields = $('#queryForm').serializeArray(); //自动序列化表单元素为JSON对象

		$.each(fields, function(i, field) {
			params[field.name] = field.value; //设置查询参数
		});

		$('#callOrderTable').datagrid('reload'); //设置好查询参数 reload 一下就可以了
	}
	//清空查询条件
	function clearForm() {
		$('#queryForm').form('clear');
		$('#orderType').combobox('select', '');
		$('#dealFlag').combobox('select', '');
		searchData();
	}

	function dealOrder(orderId, orderType, opt) {
		if(orderType=='1') {
			dealVoiceOrder(orderId, opt);
		}
		if(orderType=='2') {
			openWin('处理结算工单', '${ctx}/infobird/call/addWin?orderId=' + orderId + '&opt=' + opt + 
					'&stmp=' + (new Date()).getTime());
		}
	}
	
	function dealVoiceOrder(orderId, opt) {
		var url = '${ctx}/infobird/call/viewHis?id=' + orderId + '&opt=' + opt +
		'&stmp=' + (new Date()).getTime();
		var returnValue = window.showModalDialog(url, window,"dialogWidth=1200px;dialogHeight=500px");
		if(returnValue=='Y') {
			$('#callOrderTable').datagrid('reload'); //设置好查询参数 reload 一下就可以了
		}
	}
</script>

<style type="text/css">

</style>
  </head>
  
<body>
	<div class="easyui-layout" data-options="fit:true">
		<div region="center" style="padding: 1px;">
				<table class="easyui-datagrid" id="callOrderTable" title="Basic DataGrid"  data-options="fit:true">
				</table>
		</div>
	</div>

	
    <div id="tb" class="datagrid-toolbar" style="padding:5px;height:auto">

        <div style="margin-bottom:5px">
        	<form id="queryForm">
        		<input type="hidden" id="newOrderNo" name="newOrderNo" value="${newOrderNo}">
				<input type="hidden" id="agentName" name="agentName" value="${agentName}">
<!--         		工单类型: -->
<!--         		<select name="orderType" id="orderType" class="easyui-combobox" panelHeight="auto" style="width:100px;" > -->
<%-- 					<c:forEach items="${typeList}" var="type"> --%>
<%-- 						<option value="${type.dicValue}">${type.dicName}</option> --%>
<%-- 					</c:forEach> --%>
<!-- 				</select> -->
				工单编号:<input type="text" name="orderNo" id="orderNo" style="width:100px">
        		是否已处理:
				<select name="dealFlag" id="dealFlag" class="easyui-combobox">
					<option value="">=== 请选择 ===</option>
					<c:forEach items="${dealFlagList}" var="dic">
						<option value="${dic[0]}">${dic[2]}</option>
					</c:forEach>
				</select>
        	</form>
        </div>
        <div>
            <a href="javascript:void(0)" onclick="addrow();" id="btnadd" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
            <span style="float:right">
            	<a href="javascript:void(0)" onclick="searchData();" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
            	<a href="javascript:void(0)" onclick="clearForm();" class="easyui-linkbutton" iconCls="icon-reload">清空</a>
            </span>
                   
        </div>
    </div>
    
    <div id="innerFramWindow" class="easyui-window" data-options="closed:true,modal:true,collapsible:false,minimizable:false,maximizable:false,draggable:true,onBeforeClose:function(){}" style="overflow: hidden">
  		<iframe id="innerWinFram" scrolling="yes" frameborder="0"  src='' style="width:100%;height:100%;"></iframe>
	</div>

	<div id="MyPopWindow" modal="true" shadow="false" minimizable="false" cache="false" maximizable="false" collapsible="false" resizable="false" style="margin: 0px;padding: 0px;overflow: auto;"></div>
  </body>
</html>
